Escribo un hilo de envío de formulario con el método attr:
var href = a.attr('href'); if(href =='') return; if(href.startsWith('http') || href.startsWith('//:')){ a.attr('href',href.trim()); if(href.indexOf(location.hostname) > -1){ return; } if(href.indexOf('<?php echo $_SERVER['SERVER_NAME']; ?>') > -1){ return; } a.attr('href','go.htm?uri='+href); a.attr('rel','nofollow'); }Sin embargo, devuelve la URL sin ?, por ejemplo, quiero devolver https://example.abc.com/?ref=abc , el resultado devuelto será https://example.abc.com/ref=abc sin "?" el signo de interrogación
Estoy luchando para resolver esto y agradezco cualquier consejo útil.
Puede usar la cadena de función dividida. Divide tu URL con "?" y tomar el primer elemento.
var yourRequiredLink = href.replace("?", '')